package com.gravata.enigma.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.gravata.enigma.R;
import com.gravata.enigma.ReloadDataListener;
import com.gravata.enigma.fragments.BouquetsFragment;
import com.gravata.enigma.fragments.RegrasFragment;
import com.gravata.enigma.fragments.ServiceFragment;

public class TabsPagerAdapter extends FragmentStatePagerAdapter implements ReloadDataListener {

	private List<Fragment> fragments=new ArrayList<Fragment>();
	private String[] tabs;

	public TabsPagerAdapter(FragmentManager fm, Context context) {
		super(fm);
		String[] tabs2={context.getString(R.string.tabs_canais),context.getString(R.string.tabs_bouquets),context.getString(R.string.tabs_regras)};
		tabs=tabs2;
		fragments.add(new ServiceFragment());
		fragments.add(new BouquetsFragment());
		fragments.add(new RegrasFragment());
	}


	@Override
	public Fragment getItem(int index) {

		switch (index) {
		case 0:
			// Top Rated fragment activity
			return (Fragment) fragments.get(0);
		case 1:
			// Games fragment activity
			return (Fragment) fragments.get(1);
		case 2:
			// Movies fragment activity
			return (Fragment) fragments.get(2);
		}

		return null;
	}

	@Override
	public int getCount() {
		// get item count - equal to number of tabs
		return 3;
	}

	public String[] getTabs() {
		return tabs;
	}


	@Override
	public void onReloadData() {
		for(Fragment fragment: fragments){
			((ReloadDataListener)fragment).onReloadData();
		}
	}


	@Override
	public void onFealoadData(List<?> list) {
		// TODO Auto-generated method stub

	}
}
